home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 July / macformat52.iso / mac / Shareware Plus / Developers / YAAF v1.0 alpha 1 / Headers / Core / XString.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-24  |  2.4 KB  |  97 lines

  1. /*    XString.h
  2.  *
  3.  *        This is my implementation of a string class. I did this
  4.  *    'cause I needed a string class, and the compilers I have access
  5.  *    to don't include the standard C++ string classes.
  6.  */
  7.  
  8. /*  YAAF - Yet another application framework
  9.  *  Copyright (C) 1997 William Edward Woody and In Phase Consulting
  10.  *  
  11.  *  This library is free software; you can redistribute it
  12.  *  and/or modify it under the terms of the GNU Library
  13.  *  General Public License as published by the Free Software
  14.  *  Foundation; either version 2 of the License, or any
  15.  *  later version.
  16.  *  
  17.  *  This library is distributed in the hope that it will be
  18.  *  useful, but WITHOUT ANY WARRANTY; without even the implied
  19.  *  warranty of MERCHANTABIILITY or FITNESS FOR A PARTICULAR
  20.  *  PURPOSE. See the GNU Library General Public License for
  21.  *  more details.
  22.  *  
  23.  *  You should have received a copy of the GNU Library General
  24.  *  Public License along with this library; if not, write to the
  25.  *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  26.  *  Boston, MA 02111-1307, USA.
  27.  *  
  28.  *  To contact the author, either e-mail me at
  29.  *  woody@alumni.caltech.edu, or write to us at
  30.  *  
  31.  *          William Edward Woody
  32.  *          In Phase Consulting
  33.  *          1545 Ard Eevin Avenue
  34.  *          Glendale, CA 91202
  35.  */
  36.  
  37. #ifndef __XSTRING_H__
  38. #define __XSTRING_H__
  39.  
  40. #if defined(__MWERKS__)
  41.     #if defined(macintosh)
  42.         #pragma options align=power
  43.     #endif
  44.     #if defined(__INTEL__)
  45.         #pragma pack(push,2)
  46.     #endif
  47. #endif
  48.  
  49. /************************************************************************/
  50. /*                                                                        */
  51. /*    Standard Classes                                                    */
  52. /*                                                                        */
  53. /************************************************************************/
  54.  
  55. /*    XGString
  56.  *
  57.  *        This manages a variable-length string.
  58.  */
  59.  
  60. class XGString {
  61.     public:
  62.                                 XGString();                    // create me
  63.                                 XGString(XGString &);        // copy create me
  64.                                 XGString(const char *);        // copy create me
  65.         virtual                    ~XGString();                // delete me
  66.         
  67.         XGString                &operator = (XGString &x)
  68.                                     {
  69.                                         return operator = (x.Get());
  70.                                     }
  71.         XGString                &operator = (const char *);    // copy C string
  72.         
  73.         /*
  74.          *    String get/fetch
  75.          */
  76.         
  77.         const char                *Get(void) const
  78.                                     {
  79.                                         return fData ? fData :"";
  80.                                     }
  81.     private:
  82.         short                    fAlloc;
  83.         char                    *fData;
  84. };
  85.  
  86.  
  87. #if defined(__MWERKS__)
  88.     #if defined(macintosh)
  89.         #pragma options align=reset
  90.     #endif
  91.     #if defined(__INTEL__)
  92.         #pragma pack(pop)
  93.     #endif
  94. #endif
  95.  
  96. #endif
  97.